package game.hiram;

public abstract class Entity {
	private int x;
	private int y;
	private double dir;
	private int hp;
	private int maxHP;
	private int homeX;
	private int homeY;

	public Entity() {
		this(0, 0, 0, 100,100, 0, 0);
	}

	public Entity(int x, int y, int maxHP) {
		this(x, y, 0, maxHP,maxHP, 0, 0);
	}

	public Entity(int x, int y, double dir, int hp,int maxHP, int homeX, int homeY) {
		this.x = x;
		this.y = y;
		this.hp = hp;
		this.maxHP = maxHP;
		this.homeX = homeX;
		this.homeY = homeY;
		this.dir = dir;
	}

	public int damage(int amount) {
		if (amount <= 0) {
			return -1;
		} else {
			hp -= amount;
			return checkdeath();
		}
	}

	public int checkdeath() {
		if (hp <= 0) {
			die();
			return 1;
		}
		return 0;
	}
	public void respawn() {
		this.x = this.homeX;
		this.y = this.homeY;
		this.hp = maxHP;
	}
	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public double getDir() {
		return dir;
	}

	public int getHp() {
		return hp;
	}

	public int getMaxHP() {
		return maxHP;
	}

	public int getHomeX() {
		return homeX;
	}

	public int getHomeY() {
		return homeY;
	}

	public void setX(int x) {
		this.x = x;
	}

	public void setY(int y) {
		this.y = y;
	}

	public void setDir(double dir) {
		this.dir = dir;
	}

	private void setHp(int hp) {
		this.hp = hp;
	}

	private void setMaxHP(int maxHP) {
		this.maxHP = maxHP;
	}

	private void setHomeX(int homeX) {
		this.homeX = homeX;
	}

	private void setHomeY(int homeY) {
		this.homeY = homeY;
	}

	public abstract void die();

	public abstract void update();
}
